<template>
	<view class="content">
		<view class="uni-list" hover-class="uni-list-cell-hover">
			<view class="uni-media-list" @click="toHomeDetail(item)">
				<!-- <image class="uni-media-list-logo" :src="newsImage"></image> -->
				<view class="uni-media-list-body">
					<view class="uni-media-list-text-top">{{newsTitle}}</view>
					<view class="uni-media-list-text-bottom uni-ellipsis">{{newsCreatTime}}，共{{comment_num}}条评论</view>
				</view>
				<view class="uni-media-list-count"><uni-badge :text="newsCount" type="error"></uni-badge></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'ui-newsList',
		props: {
			item: '',
			newsImage: '',
			newsTitle: '',
			newsCreatTime: '',
			newsCount: '',
			comment_num: 0
		},
		data() {
			return {

			}
		},
		created() {

		},
		methods: {
			//打开文章
			toHomeDetail(item) {
				const params = {
					id: item.id,
					title: item.title,
					create_time: item.createtime,
					wxuser: item.wxuser.nickname,
					zancount: item.zancount,
					viewcount: item.viewcount
				}
			
				// 跳转到文章页
				// uni.navigateTo({
				// 	url: '/pages/home-detail/home-detail?params=' + JSON.stringify(params)
				// })
				
				uni.navigateTo({
					url: '/pages/home-detail/home-detail?id=' + item.id
				})
			
			},
		}
	}
</script>

<style lang="scss" scoped>
	// H5默认启用了scoped,非H5端默认并未启用scoped;
	// 界面被scoped局部化之后，不能覆盖界面里面的子组件样式，因为样式只对当前界面生效。（可以加/deep/解决）
	.uni-list {
		background-color: #FFFFFF;
		position: relative;
		width: 100%;
		display: flex;
		flex-direction: column;
	}

	.uni-list-cell-hover {
		background-color: #eee;
	}

	.uni-media-list {
		padding: 22upx 30upx;
		box-sizing: border-box;
		display: flex;
		width: 100%;
		flex-direction: row;
		border-bottom: 1px solid #eee;
	}

	.uni-media-list-logo {
		height: 84upx;
		width: 84upx;
		margin-right: 20upx;
	}

	.uni-media-list-body {
		height: 84upx;
		display: flex;
		flex: 1;
		margin: 4px;
		flex-direction: column;
		justify-content: space-between;
		align-items: flex-start;
		overflow: hidden;
	}

	.uni-media-list-text-top {
		width: 100%;
		line-height: 36upx;
		font-size: 30upx;
	}

	.uni-media-list-text-bottom {
		width: 100%;
		line-height: 30upx;
		font-size: 26upx;
		color: #8f8f94;
	}

	/* 文本溢出隐藏 */
	.uni-ellipsis {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	.uni-media-list-body {
		height: auto;
	}

	.uni-media-list-text-bottom {
		margin-top: 16upx;
	}
</style>
